package minOperations;

public class Solution {
    public int minOperations(String s) {
        return Math.min(get(create(s.length(),'0'),s),get(create(s.length(),'1'),s));
    }
    private int get(String s1,String s2){
        int ans = 0;
        for (int i = 0; i < s2.length(); i++) {
            if(s1.charAt(i)!=s2.charAt(i)) ans++;
        }
        return ans;
    }
    private String create(int n,char start){
        StringBuilder s = new StringBuilder();
        while (n>0){
            s.append(start);
            start = start=='0'?'1':'0';
        }
        return s.toString();
    }
}
